const app = getApp()
Page({
  data: {
    appName: app.config.appName,
    pageActive: 'mine',
    tabList: [{
      name: 'info',
      label: '资讯',
      path: '/pages/info/index/index',
      iconNormal: '/static/images/tabbar/info-normal.png',
      iconActive: '/static/images/tabbar/info-active.png',
    }, {
      name: 'data',
      label: '数据',
      path: '/pages/data/index/index',
      iconNormal: '/static/images/tabbar/data-normal.png',
      iconActive: '/static/images/tabbar/data-active.png',
    }, {
      name: 'service',
      label: '服务',
      path: '/pages/service/index/index',
      iconNormal: '/static/images/tabbar/service-normal.png',
      iconActive: '/static/images/tabbar/service-active.png',
    }, {
      name: 'college',
      label: '学院',
      path: '/pages/college/index/index',
      iconNormal: '/static/images/tabbar/college-normal.png',
      iconActive: '/static/images/tabbar/college-active.png',
    }, {
      name: 'mine',
      label: '我的',
      path: '/pages/mine/index/index',
      iconNormal: '/static/images/tabbar/mine-normal.png',
      iconActive: '/static/images/tabbar/mine-active.png',
    }]
  },
  onShow() {
    this.setBarColor()
  },
  tabChange(e) {
    this.setData({
      pageActive: e.currentTarget.dataset.cur
    }, () => {
      this.setBarColor()
    })
  },
  setBarColor() {
    wx.setNavigationBarColor({
      frontColor: ['data', 'mine'].includes(this.data.pageActive) ? '#ffffff' : '#000000',
      backgroundColor: '#ffffff'
    })
  },
  onShareAppMessage() {
    return {
      title: '联盟医生',
      imageUrl: '/static/images/share.jpg',
      path: '/pages/index/index'
    }
  },
})
